package com.company;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Class02 {
    public static void main(String[] args) throws IOException {
        Socket client = new Socket("127.0.0.1", 4177);

        OutputStream netOutput = client.getOutputStream();


        FileInputStream fileInputStream = new FileInputStream("k:/file/123.jpg");
        //循环，读本地文件中的数据
        byte[] buf = new byte[1024];
        int len = -1;
        while ((len = fileInputStream.read(buf)) != -1) {
            netOutput.write(buf, 0, len);
        }


        InputStream netInput = client.getInputStream();


        client.close();
        fileInputStream.close();
        netOutput.close();

    }
}
